/**
 * Created by gongxun on 16/11/23.
 */

var KwxTablePiaoLayer = GameCCSBase.extend({
    Button_piaos : null,
    Image_title : null,
    ctor: function () {
        this._super();
        this.loadCocostudio("res/ccs/KwxTablePiao.json");
        this.Panel_center = mo.seekWidgetByName(this.ccsNode, "Panel_center");
        this.Image_title = mo.seekWidgetByName(this.ccsNode, "Image_title");

        this.Button_piaos = [];
        for (var i = 0; i < 3; i++){
            var Button_piao = mo.seekWidgetByName(this.ccsNode, "Button_piao" + i);
            Button_piao.setTag(i);
            Button_piao.addTouchEventListener(function (sender, type) {
                if (mo.gameHelper.getIsTouchEnd(type)) {
                    this.sendPiaoAction(sender.getTag());
                }
            }, this);

            this.Button_piaos.push(Button_piao);
        }

        this.loadUI();

        this.setVisible(false);
    },

    loadUI : function(){

    },

    setMySelectedPiao : function(isPiao){
        this.setVisible(true);

        if (isPiao){
            for (var i = 0; i < 3; i++){
                this.Button_piaos[i].setVisible(true);
            }
            mo.gameHelper.setRootTitleText(this.Image_title, "请选择加飘");
        }else{
            for (var i = 0; i < 3; i++){
                this.Button_piaos[i].setVisible(false);
            }
            mo.gameHelper.setRootTitleText(this.Image_title, "等待其他玩家选择加飘");
        }
    },

    sendPiaoAction : function(code){
        mo.gameMsgManager.sendActionRequestkwx(1, [code], []);
    }
});